package com;

import java.util.concurrent.CompletionService;
import java.util.function.Consumer;

/**
 * 用于计算，不需要返回
 */
public class ConsumerOne {
    public static void add(int i){
        Consumer<Integer> consumer = (x)->{
            System.out.println("我要"+x*2+"个姑娘");
        };
        consumer.accept(i);

    }
    public static void then(int i){
        Consumer<Integer> c1 = (x)->{
            System.out.println(String.format("1代第%s个姑娘 ",x));
        };
        Consumer<Integer> c2 = (x)->{
            System.out.println(String.format("2代第%s个姑娘 ",x));
          //  throw new RuntimeException("姑娘已死，有事烧指");
        };
        Consumer<Integer> c3 = (x)->{
            System.out.println(String.format("3代第%s个姑娘 ",x));

        };
        c1.andThen(c2).andThen(c1).andThen(c2).andThen(c3).accept(19);

    }



    public static void main(String[] args) {
        add(10);
        then(18);
    }
}
